import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import java.io.IOException;

public class SearchHelper {
    public static int googlePositions(String phrase) throws IOException {
//        Document doc;
//        String googleURL = "http://www.google.ru/search?hl=ru&source=hp&biw=1280&bih=566&q=" + phrase + "&aq=1&aqi=g10&aql=&oq=&start=" + page;
//        doc = Jsoup.connect(googleURL).
//                header("user-agent", "Mozilla/5.0 (Windows NT 5.1; rv:5.0) Gecko/20100101 Firefox/5.0").
//                header("Cookie", "t=p; yandexuid=3271890011313154616; spravka=dD0xMzEzMTU0NjI3O2k9MTA5LjIwNS4yNTMuMTM1O3U9MTMxMzE1NDYyNzU0Mzk1MTkxNDtoPWIxZjY2ZjA5YmQzZjMyYmNmYTIwNGFhMTdmMzhmNjk2; yp=1629378627.sp.; fuid01=4d726ae12b1a1ac0.N9hJY3OOtWG-kEtar5NvfvMUs1Xo_8AUqbE-fG1uUYhwf2PZq1e_rMNyTIPcAliV5rOj5oRQaNMCW7Z2qn2HXaeA_Otjy40U2yeL3hFKkrbBAo6y88nb2eM2jOvZk-KQ").
//                timeout(10000).get();
//        Element res = doc.getElementById("rso");
//        Elements cites = res.select("cite");
//        int exceptions = 0;
//        int position = 0;
//        for (Element cite : cites) {
//            position++;
//            if (isException(cite.text())) {
//                exceptions++;
//            }
//            positions.put(position - exceptions + page, cite.text());
//        }
        return -1;
    }

    private static boolean isException(String text) {
        return text.contains("youtube.com") || text.contains("smotri.com");
    }

}
